home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / Issue59 / Arch / Sample / UnitFormMain.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  2000-05-29  |  2.5 KB  |  98 lines

  1. unit UnitFormMain;
  2. {
  3. After you've added a new list add an action to display the list. Do this by
  4. adding an action to component ActionList. In the action's execute method
  5. put a line of code like: "FormListOrders.ShowForm;" For this to work you need
  6. to add FormListOrders as a TFormBase class method (function)
  7. }
  8. interface
  9.  
  10. uses
  11.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  12.   Menus, ToolWin, ComCtrls, ActnList, ImgList, UnitFormBase;
  13.  
  14. type
  15.   TFormMain = class(TFormBase)
  16.     ActionList: TActionList;
  17.     ToolBarMain: TToolBar;
  18.     MainMenu: TMainMenu;
  19.     File1: TMenuItem;
  20.     Find1: TMenuItem;
  21.     Exit1: TMenuItem;
  22.     ActionTerminate: TAction;
  23.     ActionSaveAll: TAction;
  24.     SaveAll1: TMenuItem;
  25.     N1: TMenuItem;
  26.     ToolButton5: TToolButton;
  27.     ActionFindOrders: TAction;
  28.     Orders1: TMenuItem;
  29.     ToolButton1: TToolButton;
  30.     ToolButton2: TToolButton;
  31.     ActionFindCustomer: TAction;
  32.     ToolButton3: TToolButton;
  33.     Customer1: TMenuItem;
  34.     procedure ActionTerminateExecute(Sender: TObject);
  35.     procedure ActionSaveAllExecute(Sender: TObject);
  36.     procedure ActionSaveAllUpdate(Sender: TObject);
  37.     procedure ActionFindOrdersExecute(Sender: TObject);
  38.     procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
  39.     procedure ActionFindCustomerExecute(Sender: TObject);
  40.   private
  41.   public
  42.   end;
  43.  
  44. var FormMain: TFormMain;
  45.  
  46. implementation
  47.  
  48. uses
  49.   UnitFormListBase
  50. , UnitObjectBase
  51. , UnitFormListOrders
  52. , UnitFormListCustomer
  53.   ;
  54.  
  55. {$R *.DFM}
  56.  
  57. procedure TFormMain.ActionTerminateExecute(Sender: TObject);
  58. begin
  59.   inherited;
  60.     Application.Terminate;
  61. end;
  62.  
  63. procedure TFormMain.ActionSaveAllExecute(Sender: TObject);
  64. begin
  65.   inherited;
  66.   TObjectBase.SaveAll;
  67. end;
  68.  
  69. procedure TFormMain.ActionSaveAllUpdate(Sender: TObject);
  70. begin
  71.   inherited;
  72.   ActionSaveAll.Enabled := TObjectBase.AnyUpdatesPending;
  73. end;
  74.  
  75. procedure TFormMain.ActionFindOrdersExecute(Sender: TObject);
  76. begin
  77.   inherited;
  78.   // Using new integer means we get a new list every time the user chooses "Find"
  79.   TFormListOrders.FetchForm(NewInteger).ShowForm;
  80. end;
  81.  
  82. procedure TFormMain.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
  83. begin
  84.   inherited;
  85.   TFormBase.CloseAll;
  86.   Application.ProcessMessages;
  87.   CanClose := (TFormBase.FormCount = 0);
  88. end;
  89.  
  90. procedure TFormMain.ActionFindCustomerExecute(Sender: TObject);
  91. begin
  92.   inherited;
  93.   // Using new integer means we get a new list every time the user chooses "Find"
  94.   TFormListCustomer.FetchForm(NewInteger).ShowForm;
  95. end;
  96.  
  97. end.
  98.